<template>
  <div>
    <div class="message-box">
      <div>资讯展示</div>
      <div class="message">
        <div class="flex-box">
          <div>供应商数量</div>
          <!-- <div class="message-div" @click="open1">{{ Messagekey[0] }}</div> -->
          <div>
            <el-carousel :interval="4000" type="card" height="100px" indicator-position="none">
              <el-carousel-item v-for="item in Companyname" :key="item.id" >
                <h3 class="medium" @click="open1(item)">{{ item.title }}</h3>
              </el-carousel-item>
            </el-carousel>
          </div>
        </div>
        <div class="flex-box">
          <div>需求数量</div>
          <div class="message-div" @click="open2">{{ Messagekey[1] }}</div>
        </div>
      </div>
    </div>
    <!-- 弹框 -->
    <Demandprop :opendemand="opendemand1" :demanditem="demanditem" type="2" @opendemandevent="opendemandval1"></Demandprop>
    <Demandprop :opendemand="opendemand2"  type="1" @opendemandevent="opendemandval2"></Demandprop>
  </div>
</template>

<script>
import { demand ,selectCountMessage} from "@/api/bigscreen/bigscreen.js";
import Demandprop from "../demandprop/demandprop.vue";
export default {
  components: { Demandprop },
  data() {
    return {
      Messagekey: [],
      opendemand1: false,
      opendemand2: false,
      pageNum: 1,
      pageSize: 10,
      Companyname:[],
      demanditem:[]
    };
  },
  mounted() {
    this.getselectCountMessage();
  },
  
  methods: {
    // 获取恭喜数据
    getselectCountMessage() {
         selectCountMessage().then((res) => {
           if (res.code === 200) {
             const { data } = res;
             const Messagekey = Object.values(data);
             // const Messagevalues = Object.values(data)[0]
             this.Messagekey = Messagekey;
             // this.Messagevalues = Messagevalues
           }
         });
      const pageNum = this.pageNum
      const pageSize = this.pageSize
      demand({ pageNum, pageSize }).then((res) => {
        console.log(res.rows,'rowwww')
        this.Companyname = res.rows
      })
    },

    // 弹框
    open1(item) {
      this.opendemand1 = true;
      // 创建一个空数组
       this.demanditem.push(item);
    },
    open2() {
      this.opendemand2 = true;
      // this.demanditem = 2;
    },
    opendemandval1(val) {
      this.opendemand1 = val;
    },
    opendemandval2(val) {
      this.opendemand2 = val;
    }
  },
};
</script>

<style lang="scss" scoped>
.message-box {
  padding: 20px 40px;
  color: #09f5fc;

  .message {
    display: flex;
    justify-content: space-between;
    color: aliceblue;
    padding: 20px 0;

    .flex-box {
      display: flex;
      flex: 1;
      justify-content: space-between;
    }
    .flex-box:nth-child(1) {
      display: flex;
      flex: 1.5;
      flex-direction: column;
    }

    .message-div {
      // display: block;
      width: 50px;
      height: 40px;
      line-height: 40px;
      border-radius: 5px;
      margin-left: 20px;
      text-align: center;
      border: 1px solid #09f5fc;
    }
  }
}
.el-carousel__item h3 {
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    opacity: 0.75;
    line-height: 100px;
    text-align: center;
    margin: 0;
  }
  
  .el-carousel__item:nth-child(2n) {
    background-color: #2876b6;
  }
  
  .el-carousel__item:nth-child(2n+1) {
    background-color: #2876b6;
  }
</style>
